package com.lemon.boot.controller;

import com.lemon.boot.common.annotation.NotAuthorization;
import com.lemon.boot.po.CityPO;
import com.lemon.boot.service.ICityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.Collections;
import java.util.List;

/**
 * 城市表控制层
 *
 * @author Lemon
 * @since 2024-02-29
 */
@Log4j2
@Api(tags = "城市管理")
@RestController
@RequestMapping("city")
public class CityController {
    @Resource
    private ICityService iCityService;

    /**
     * 根据parentId查询列表数据
     *
     * @return
     */
    @PermitAll
    @NotAuthorization
    @ApiOperation(value = "根据parentId查询列表数据")
    @GetMapping("getByParentId/{parentId}")
    public List<CityPO> getByParentId(@PathVariable("parentId") Long parentId) {
        return iCityService.listByMap(Collections.singletonMap("parent_id", parentId));
    }
}